import request from '@/utils/request'

const api_name = '/admin/comment'

// 分页查询评论
export const GetCommentPageList = (page, limit) => {
  return request({
    url: `${api_name}/${page}/${limit}`,
    method: 'get',
  })
}

// 添加评论
export const SaveComment = commentDto => {
  return request({
    url: `${api_name}/save`,
    method: 'post',
    data: commentDto,
  })
}

// 删除评论
export const RemoveComment = id => {
  return request({
    url: `${api_name}/remove/${id}`,
    method: 'delete',
  })
}

// 修改评论状态
export const UpdateCommentStatus = (id, status) => {
  return request({
    url: `${api_name}/updateStatus/${id}/${status}`,
    method: 'put',
  })
}

// 根据帖子ID查询评论列表
export const GetCommentsByPostId = (postId, page = 1, limit = 10) => {
  return request({
    url: `${api_name}/findByPostId/${postId}`,
    method: 'get',
    params: { page, limit },
  })
}
